package com.kaiwukj.android.ufamily.mvp.ui.page.dynamic.person;

import android.os.Bundle;
import android.widget.TextView;

import com.kaiwukj.android.ufamily.R;
import com.kaiwukj.android.ufamily.app.base.review.BaseFragment;
import com.kaiwukj.android.ufamily.mvp.http.entity.result.UserResult;

import butterknife.BindView;

public class PersonIndexChildFragment extends BaseFragment {

    @BindView(R.id.tv_name)
    TextView tvName;
    @BindView(R.id.tv_sign)
    TextView tvSign;
    @BindView(R.id.tv_sex)
    TextView tvSex;
    @BindView(R.id.tv_area)
    TextView tvArea;
    @BindView(R.id.tv_job)
    TextView tvJob;
    @BindView(R.id.tv_community)
    TextView tvCommunity;

    UserResult result;


    public static PersonIndexChildFragment newInstance() {
        return new PersonIndexChildFragment();
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_person_index_child;
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initData(Bundle savedInstanceState) {
        initResult(result);
    }

    void setData(UserResult result) {
        this.result = result;
        if (isSupportVisible()) {
            initResult(result);
        }
    }

    private void initResult(UserResult result) {
        if (result == null) return;
        tvName.setText(result.getNickName());
        tvSign.setText(result.getSignature());
        tvSex.setText(result.getGenderStr());
        tvArea.setText(result.getRegion());
        tvJob.setText(result.getIndustry());
        tvCommunity.setText(result.getLastCommunityName());
    }
}
